﻿

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;

namespace Ogdi.Data.DataLoader
{
    [Serializable]
    public class EntityAlreadyExistsException : Exception
    {
        public EntityAlreadyExistsException(string entitySetName, string RowKeyColumn, string RowKeyValue, string ParKeyColumn, string ParKeyValue)
            : base(constructMessage(entitySetName, RowKeyColumn, RowKeyValue, ParKeyColumn, ParKeyValue))
        {
        }

        private static string constructMessage(string entitySetName, string RowKeyColumn, string RowKeyValue, string ParKeyColumn, string ParKeyValue)
        {
            string condition1 = String.Format("{0} = '{1}'", RowKeyColumn, RowKeyValue);
            string condition2 = String.Format("{0} = '{1}'", ParKeyColumn, ParKeyValue);
            var mess = entitySetName + " with " + condition1 + " and " + condition2;
            mess += " already exists in the storage.";
            return mess;
        }
    }
}
